package com.example.meimessage;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabWidget;

import com.example.meimessage.favorite.Favorite;
import com.example.meimessage.group.Group_MainActivity;

public class MainFragment extends BaseFragment{
	
	LocalActivityManager localActivityManager;
	TabHost tabHost;
	TabWidget tabWidget;
	
	public MainFragment() {
		super();
	}
	
	@SuppressWarnings("deprecation")
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		mMainView = inflater.inflate(R.layout.fragment_tabhost, container, false);
		findTabView();
		localActivityManager = new LocalActivityManager(getActivity(), true);
		localActivityManager.dispatchCreate(savedInstanceState);
		tabHost.setup(localActivityManager);

		//MessageTab
		Intent localIntent_message = new Intent();
		localIntent_message.setClass(getActivity(), Message_MainActivity.class);
		View view_messages = this.getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_tabview_message, null);
		tabHost.addTab(tabHost.newTabSpec("Messages").setIndicator(view_messages).setContent(localIntent_message));
		
		
		Intent localIntent_group = new Intent();
		localIntent_group.setClass(getActivity(), Favorite.class);
		View view_group = this.getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_tabview_group, null);
		tabHost.addTab(tabHost.newTabSpec("Messages").setIndicator(view_group).setContent(localIntent_group));


		Intent localIntent_favorite = new Intent();
		localIntent_favorite.setClass(getActivity(), Group_MainActivity.class);
		View view_favorite = this.getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_tabview_favorite, null);
		tabHost.addTab(tabHost.newTabSpec("Messages").setIndicator(view_favorite).setContent(localIntent_favorite));
		
		return mMainView;
	}
	
	public void findTabView() {
		tabHost = (TabHost) mMainView.findViewById(android.R.id.tabhost);
	}
    	
}
